package us.mooresr.geartrack.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.geartrack.shared.model.Person;
import com.google.gwt.event.shared.HasHandlers;

public class PersonCreatedEvent extends
		GwtEvent<PersonCreatedEvent.PersonCreatedHandler> {

	public static Type<PersonCreatedHandler> TYPE = new Type<PersonCreatedHandler>();
	private Person person;

	public interface PersonCreatedHandler extends EventHandler {
		void onBorrowerCreated(PersonCreatedEvent event);
	}

	public PersonCreatedEvent(Person person) {
		this.person = person;
	}

	public Person getBorrower() {
		return person;
	}

	@Override
	protected void dispatch(PersonCreatedHandler handler) {
		handler.onBorrowerCreated(this);
	}

	@Override
	public Type<PersonCreatedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<PersonCreatedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Person person) {
		source.fireEvent(new PersonCreatedEvent(person));
	}
}
